<template>
  <Modal v-model="showAc" title="请选择需要关联广告的活动" width="80%" :footer-hide="true">
    <div class="form_box">
      <dt-grid ref="table" :onFetch="onFetch" :page="page" :height="400" />
      <div class="btn_box">
        <Button style="margin-top: 24px" @click="cancel">关闭</Button>
      </div>
    </div>
  </Modal>
</template>

<script>
  import column from '../opt/associationColumn.js'
  import activityMgr from '@/biz/activity/activity'
  export default {
    data() {
      return {
        showAc: false,
        page: {
          total: 0
        },
        acId: null,
        statusList: null
      }
    },

    mounted() {},

    methods: {
      onFetch(info) {
        info.statusList = this.statusList
        info.acId = this.acId
        return activityMgr.basicsList(info).then((res) => {
          console.log('表格数据', res)
          this.page.total = res.total
          return res.list
        })
      },
      cancel() {
        this.showAc = false
      },
      show(acId) {
        if (acId) {
          this.acId = acId
          this.statusList = null
        } else {
          this.acId = null
          this.statusList = ['NO_START', 'UNDER_WAY']
        }
        this.$refs.table.init(this, new column(this))
        this.$refs.table.fetch()
        this.showAc = true
      },
      associationAc(ac) {
        this.$emit('getAc', ac)
        this.showAc = false
      }
    }
  }
</script>

<style lang="scss" scoped>
  .btn_box {
    text-align: right;
  }
</style>
